package patterns.mvc;

/**
 * Created by thinkpad on 16-12-11.
 * 演示MVC模式的用法
 */
public class MVCPatternDemo {
    public static void main(String[] args){
        //从数据获取学生记录
        Student model = retriveStudentFromDatabase();
        //创建视图view，显示输出学生信息。
        StudentView view = new StudentView();
        StudentController controller = new StudentController(model,view);
        controller.updateView();

        //更新数据，从而通过controller来更新view
          controller.setStudentName("Robert");
        controller.updateView();


    }

    private static Student retriveStudentFromDatabase() {
        Student student = new Student();
        student.setName("Tom");
        student.setRollNo("7");
        return student;
    }
}
